/*
 * ad5291.c
 *
 * Created: 27.02.2013 13:34:11
 *  Author: saenko
 */ 
#include <avr/io.h>
#include <util/delay.h>
#include <avr/interrupt.h>

//#include "uart.h"
#include "SPI.h"
#include "ad5291.h"

uint16_t read_ctrl_reg(void)
{
	uint16_t data_in;
	
	spi_write(0b0001110000000000);
	
	data_in = spi_write(0b0000000000000000);
	
	return data_in;
}

void ad5291_set_vol(uint16_t vol)
{
	uint16_t temp;
	
	temp = 0b0000010000000000 + vol;
	
	spi_write(temp);
	
	
}

uint16_t ad5291_read_RDAC(void)
{
	uint16_t data_in;
	
	spi_write(0b0000100000000000);
	
	data_in = spi_write(0b0000000000000000);
	
	return data_in;
}

void ad5291_init(void)
{
	spi_write(0x1802);
}